class Node:
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children


from typing import *


class Solution:
    def postorder(self, root: "Node") -> List[int]:

        ans = []

        def f(node):
            if node is None:
                return
            for c in node.children:
                f(c)
            ans.append(node.val)

        f(root)
        return ans
